package com.cl.ks.repository;


import com.cl.ks.entity.KsDataField;
import com.cl.mvc.repository.BaseRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface KsDataFieldRepository extends BaseRepository<KsDataField> {

    @Query(nativeQuery = true, value = "select * from ks_data_field\n" +
            "where data_type_code in (select data_type_code\n" +
            "                         from (select data_type_code, count(1) as count\n" +
            "                               from ks_data_field\n" +
            "                               where code in (:codeList)\n" +
            "                               group by data_type_code\n" +
            "                               order by count desc\n" +
            "                               limit 1) as a)")
    List<KsDataField> listKsDataField(String[] codeList);
}